3.1.58 \(\int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 (A+B \tan (e+f x)+C \tan ^2(e+f x)) \, dx\) [58]

3.1.58.1 Optimal result
3.1.58.2 Mathematica [C] (verified)
3.1.58.3 Rubi [A] (verified)
3.1.58.4 Maple [A] (verified)
3.1.58.5 Fricas [A] (verification not implemented)
3.1.58.6 Sympy [B] (verification not implemented)
3.1.58.7 Maxima [A] (verification not implemented)
3.1.58.8 Giac [B] (verification not implemented)
3.1.58.9 Mupad [B] (verification not implemented)

3.1.58.1 Optimal result

Integrand size = 45, antiderivative size = 443 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=-\left (\left (a^2 \left (c^2 C+2 B c d-C d^2-A \left (c^2-d^2\right )\right )-b^2 \left (c^2 C+2 B c d-C d^2-A \left (c^2-d^2\right )\right )+2 a b \left (2 c (A-C) d+B \left (c^2-d^2\right )\right )\right ) x\right )+\frac {\left (2 a b \left (c^2 C+2 B c d-C d^2-A \left (c^2-d^2\right )\right )-a^2 \left (2 c (A-C) d+B \left (c^2-d^2\right )\right )+b^2 \left (2 c (A-C) d+B \left (c^2-d^2\right )\right )\right ) \log (\cos (e+f x))}{f}+\frac {d \left (2 a b (A c-c C-B d)+a^2 (B c+(A-C) d)-b^2 (B c+(A-C) d)\right ) \tan (e+f x)}{f}+\frac {\left (a^2 B-b^2 B+2 a b (A-C)\right ) (c+d \tan (e+f x))^2}{2 f}+\frac {\left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (2 c^2 C-5 B c d+20 (A-C) d^2\right )\right ) (c+d \tan (e+f x))^3}{60 d^3 f}-\frac {b (2 b c C-5 b B d-2 a C d) \tan (e+f x) (c+d \tan (e+f x))^3}{20 d^2 f}+\frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f} \]

output
-(a^2*(c^2*C+2*B*c*d-C*d^2-A*(c^2-d^2))-b^2*(c^2*C+2*B*c*d-C*d^2-A*(c^2-d^ 
2))+2*a*b*(2*c*(A-C)*d+B*(c^2-d^2)))*x+(2*a*b*(c^2*C+2*B*c*d-C*d^2-A*(c^2- 
d^2))-a^2*(2*c*(A-C)*d+B*(c^2-d^2))+b^2*(2*c*(A-C)*d+B*(c^2-d^2)))*ln(cos( 
f*x+e))/f+d*(2*a*b*(A*c-B*d-C*c)+a^2*(B*c+(A-C)*d)-b^2*(B*c+(A-C)*d))*tan( 
f*x+e)/f+1/2*(B*a^2-B*b^2+2*a*b*(A-C))*(c+d*tan(f*x+e))^2/f+1/60*(8*a^2*C* 
d^2-10*a*b*d*(-4*B*d+C*c)+b^2*(2*c^2*C-5*B*c*d+20*(A-C)*d^2))*(c+d*tan(f*x 
+e))^3/d^3/f-1/20*b*(-5*B*b*d-2*C*a*d+2*C*b*c)*tan(f*x+e)*(c+d*tan(f*x+e)) 
^3/d^2/f+1/5*C*(a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^3/d/f
 
3.1.58.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 6.55 (sec) , antiderivative size = 383, normalized size of antiderivative = 0.86 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}+\frac {\frac {b (-2 b c C+5 b B d+2 a C d) \tan (e+f x) (c+d \tan (e+f x))^3}{4 d f}-\frac {\frac {\left (-8 a^2 C d^2+10 a b d (c C-4 B d)-b^2 \left (2 c^2 C-5 B c d+20 (A-C) d^2\right )\right ) (c+d \tan (e+f x))^3}{3 d f}-\frac {10 \left (d \left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \left (i (c+i d)^2 \log (i-\tan (e+f x))-i (c-i d)^2 \log (i+\tan (e+f x))-2 d^2 \tan (e+f x)\right )+\left (a^2 B-b^2 B+2 a b (A-C)\right ) d \left ((i c-d)^3 \log (i-\tan (e+f x))-(i c+d)^3 \log (i+\tan (e+f x))+6 c d^2 \tan (e+f x)+d^3 \tan ^2(e+f x)\right )\right )}{f}}{4 d}}{5 d} \]

input
Integrate[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x 
] + C*Tan[e + f*x]^2),x]
 
output
(C*(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])^3)/(5*d*f) + ((b*(-2*b*c*C 
+ 5*b*B*d + 2*a*C*d)*Tan[e + f*x]*(c + d*Tan[e + f*x])^3)/(4*d*f) - (((-8* 
a^2*C*d^2 + 10*a*b*d*(c*C - 4*B*d) - b^2*(2*c^2*C - 5*B*c*d + 20*(A - C)*d 
^2))*(c + d*Tan[e + f*x])^3)/(3*d*f) - (10*(d*(2*a*b*(A*c - c*C + B*d) + a 
^2*(B*c - (A - C)*d) - b^2*(B*c - (A - C)*d))*(I*(c + I*d)^2*Log[I - Tan[e 
 + f*x]] - I*(c - I*d)^2*Log[I + Tan[e + f*x]] - 2*d^2*Tan[e + f*x]) + (a^ 
2*B - b^2*B + 2*a*b*(A - C))*d*((I*c - d)^3*Log[I - Tan[e + f*x]] - (I*c + 
 d)^3*Log[I + Tan[e + f*x]] + 6*c*d^2*Tan[e + f*x] + d^3*Tan[e + f*x]^2))) 
/f)/(4*d))/(5*d)
 
3.1.58.3 Rubi [A] (verified)

Time = 2.16 (sec) , antiderivative size = 470, normalized size of antiderivative = 1.06, number of steps used = 14, number of rules used = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.311, Rules used = {3042, 4130, 25, 3042, 4120, 25, 3042, 4113, 3042, 4011, 3042, 4008, 3042, 3956}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )dx\)

\(\Big \downarrow \) 4130

\(\displaystyle \frac {\int -\left ((a+b \tan (e+f x)) (c+d \tan (e+f x))^2 \left ((2 b c C-2 a d C-5 b B d) \tan ^2(e+f x)-5 (A b-C b+a B) d \tan (e+f x)+2 b c C-a (5 A-3 C) d\right )\right )dx}{5 d}+\frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\int (a+b \tan (e+f x)) (c+d \tan (e+f x))^2 \left ((2 b c C-2 a d C-5 b B d) \tan ^2(e+f x)-5 (A b-C b+a B) d \tan (e+f x)+2 b c C-a (5 A-3 C) d\right )dx}{5 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\int (a+b \tan (e+f x)) (c+d \tan (e+f x))^2 \left ((2 b c C-2 a d C-5 b B d) \tan (e+f x)^2-5 (A b-C b+a B) d \tan (e+f x)+2 b c C-a (5 A-3 C) d\right )dx}{5 d}\)

\(\Big \downarrow \) 4120

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}-\frac {\int -(c+d \tan (e+f x))^2 \left (-c (2 c C-5 B d) b^2+10 a c C d b-4 a^2 (5 A-3 C) d^2-\left (\left (2 C c^2-5 B d c+20 (A-C) d^2\right ) b^2-10 a d (c C-4 B d) b+8 a^2 C d^2\right ) \tan ^2(e+f x)-20 \left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )dx}{4 d}}{5 d}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x))^2 \left (-c (2 c C-5 B d) b^2+10 a c C d b-4 a^2 (5 A-3 C) d^2-\left (\left (2 C c^2-5 B d c+20 (A-C) d^2\right ) b^2-10 a d (c C-4 B d) b+8 a^2 C d^2\right ) \tan ^2(e+f x)-20 \left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )dx}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x))^2 \left (-c (2 c C-5 B d) b^2+10 a c C d b-4 a^2 (5 A-3 C) d^2-\left (\left (2 C c^2-5 B d c+20 (A-C) d^2\right ) b^2-10 a d (c C-4 B d) b+8 a^2 C d^2\right ) \tan (e+f x)^2-20 \left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )dx}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 4113

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x))^2 \left (20 \left (-\left ((A-C) a^2\right )+2 b B a+b^2 (A-C)\right ) d^2-20 \left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x))^2 \left (20 \left (-\left ((A-C) a^2\right )+2 b B a+b^2 (A-C)\right ) d^2-20 \left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 4011

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x)) \left (-20 \left ((A c-C c-B d) a^2-2 b (B c+(A-C) d) a-b^2 (A c-C c-B d)\right ) d^2-20 \left ((B c+(A-C) d) a^2+2 b (A c-C c-B d) a-b^2 (B c+(A-C) d)\right ) \tan (e+f x) d^2\right )dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}-\frac {10 d^2 \left (a^2 B+2 a b (A-C)-b^2 B\right ) (c+d \tan (e+f x))^2}{f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {\int (c+d \tan (e+f x)) \left (-20 \left ((A c-C c-B d) a^2-2 b (B c+(A-C) d) a-b^2 (A c-C c-B d)\right ) d^2-20 \left ((B c+(A-C) d) a^2+2 b (A c-C c-B d) a-b^2 (B c+(A-C) d)\right ) \tan (e+f x) d^2\right )dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}-\frac {10 d^2 \left (a^2 B+2 a b (A-C)-b^2 B\right ) (c+d \tan (e+f x))^2}{f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 4008

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {20 d^2 \left (-\left (a^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )+2 a b \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+b^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right ) \int \tan (e+f x)dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}+20 d^2 x \left (a^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+2 a b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )-b^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )\right )-\frac {20 d^3 \tan (e+f x) \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right )}{f}-\frac {10 d^2 \left (a^2 B+2 a b (A-C)-b^2 B\right ) (c+d \tan (e+f x))^2}{f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {20 d^2 \left (-\left (a^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )+2 a b \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+b^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right ) \int \tan (e+f x)dx-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}+20 d^2 x \left (a^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+2 a b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )-b^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )\right )-\frac {20 d^3 \tan (e+f x) \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right )}{f}-\frac {10 d^2 \left (a^2 B+2 a b (A-C)-b^2 B\right ) (c+d \tan (e+f x))^2}{f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {C (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^3}{5 d f}-\frac {\frac {-\frac {(c+d \tan (e+f x))^3 \left (8 a^2 C d^2-10 a b d (c C-4 B d)+b^2 \left (20 d^2 (A-C)-5 B c d+2 c^2 C\right )\right )}{3 d f}-\frac {20 d^2 \log (\cos (e+f x)) \left (-\left (a^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )+2 a b \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+b^2 \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )\right )}{f}+20 d^2 x \left (a^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+2 a b \left (2 c d (A-C)+B \left (c^2-d^2\right )\right )-b^2 \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )\right )-\frac {20 d^3 \tan (e+f x) \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right )}{f}-\frac {10 d^2 \left (a^2 B+2 a b (A-C)-b^2 B\right ) (c+d \tan (e+f x))^2}{f}}{4 d}+\frac {b \tan (e+f x) (-2 a C d-5 b B d+2 b c C) (c+d \tan (e+f x))^3}{4 d f}}{5 d}\)

input
Int[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C* 
Tan[e + f*x]^2),x]
 
output
(C*(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])^3)/(5*d*f) - ((b*(2*b*c*C - 
 5*b*B*d - 2*a*C*d)*Tan[e + f*x]*(c + d*Tan[e + f*x])^3)/(4*d*f) + (20*d^2 
*(a^2*(c^2*C + 2*B*c*d - C*d^2 - A*(c^2 - d^2)) - b^2*(c^2*C + 2*B*c*d - C 
*d^2 - A*(c^2 - d^2)) + 2*a*b*(2*c*(A - C)*d + B*(c^2 - d^2)))*x - (20*d^2 
*(2*a*b*(c^2*C + 2*B*c*d - C*d^2 - A*(c^2 - d^2)) - a^2*(2*c*(A - C)*d + B 
*(c^2 - d^2)) + b^2*(2*c*(A - C)*d + B*(c^2 - d^2)))*Log[Cos[e + f*x]])/f 
- (20*d^3*(2*a*b*(A*c - c*C - B*d) + a^2*(B*c + (A - C)*d) - b^2*(B*c + (A 
 - C)*d))*Tan[e + f*x])/f - (10*(a^2*B - b^2*B + 2*a*b*(A - C))*d^2*(c + d 
*Tan[e + f*x])^2)/f - ((8*a^2*C*d^2 - 10*a*b*d*(c*C - 4*B*d) + b^2*(2*c^2* 
C - 5*B*c*d + 20*(A - C)*d^2))*(c + d*Tan[e + f*x])^3)/(3*d*f))/(4*d))/(5* 
d)
 

3.1.58.3.1 Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

rule 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 

rule 4130
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_. 
) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*(a + b*Tan[e + f*x])^m*((c + d*Tan[ 
e + f*x])^(n + 1)/(d*f*(m + n + 1))), x] + Simp[1/(d*(m + n + 1))   Int[(a 
+ b*Tan[e + f*x])^(m - 1)*(c + d*Tan[e + f*x])^n*Simp[a*A*d*(m + n + 1) - C 
*(b*c*m + a*d*(n + 1)) + d*(A*b + a*B - b*C)*(m + n + 1)*Tan[e + f*x] - (C* 
m*(b*c - a*d) - b*B*d*(m + n + 1))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && 
 NeQ[c^2 + d^2, 0] && GtQ[m, 0] &&  !(IGtQ[n, 0] && ( !IntegerQ[m] || (EqQ[ 
c, 0] && NeQ[a, 0])))
 
3.1.58.4 Maple [A] (verified)

Time = 0.26 (sec) , antiderivative size = 392, normalized size of antiderivative = 0.88

method result size
parts \(\frac {\left (2 A \,a^{2} c d +2 A a b \,c^{2}+B \,a^{2} c^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (B \,b^{2} d^{2}+2 C a b \,d^{2}+2 C \,b^{2} c d \right ) \left (\frac {\tan \left (f x +e \right )^{4}}{4}-\frac {\tan \left (f x +e \right )^{2}}{2}+\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {\left (A \,b^{2} d^{2}+2 B a b \,d^{2}+2 B \,b^{2} c d +a^{2} C \,d^{2}+4 C a b c d +C \,b^{2} c^{2}\right ) \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {\left (A \,a^{2} d^{2}+4 A a b c d +A \,b^{2} c^{2}+2 B \,a^{2} c d +2 B a b \,c^{2}+C \,a^{2} c^{2}\right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {\left (2 A a b \,d^{2}+2 A \,b^{2} c d +B \,a^{2} d^{2}+4 B a b c d +B \,b^{2} c^{2}+2 C \,a^{2} c d +2 C a b \,c^{2}\right ) \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+A \,a^{2} c^{2} x +\frac {C \,b^{2} d^{2} \left (\frac {\tan \left (f x +e \right )^{5}}{5}-\frac {\tan \left (f x +e \right )^{3}}{3}+\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(392\)
norman \(\left (A \,a^{2} c^{2}-A \,a^{2} d^{2}-4 A a b c d -A \,b^{2} c^{2}+A \,b^{2} d^{2}-2 B \,a^{2} c d -2 B a b \,c^{2}+2 B a b \,d^{2}+2 B \,b^{2} c d -C \,a^{2} c^{2}+a^{2} C \,d^{2}+4 C a b c d +C \,b^{2} c^{2}-C \,b^{2} d^{2}\right ) x +\frac {\left (A \,a^{2} d^{2}+4 A a b c d +A \,b^{2} c^{2}-A \,b^{2} d^{2}+2 B \,a^{2} c d +2 B a b \,c^{2}-2 B a b \,d^{2}-2 B \,b^{2} c d +C \,a^{2} c^{2}-a^{2} C \,d^{2}-4 C a b c d -C \,b^{2} c^{2}+C \,b^{2} d^{2}\right ) \tan \left (f x +e \right )}{f}+\frac {\left (A \,b^{2} d^{2}+2 B a b \,d^{2}+2 B \,b^{2} c d +a^{2} C \,d^{2}+4 C a b c d +C \,b^{2} c^{2}-C \,b^{2} d^{2}\right ) \tan \left (f x +e \right )^{3}}{3 f}+\frac {\left (2 A a b \,d^{2}+2 A \,b^{2} c d +B \,a^{2} d^{2}+4 B a b c d +B \,b^{2} c^{2}-B \,b^{2} d^{2}+2 C \,a^{2} c d +2 C a b \,c^{2}-2 C a b \,d^{2}-2 C \,b^{2} c d \right ) \tan \left (f x +e \right )^{2}}{2 f}+\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{5}}{5 f}+\frac {b d \left (b d B +2 C a d +2 C b c \right ) \tan \left (f x +e \right )^{4}}{4 f}+\frac {\left (2 A \,a^{2} c d +2 A a b \,c^{2}-2 A a b \,d^{2}-2 A \,b^{2} c d +B \,a^{2} c^{2}-B \,a^{2} d^{2}-4 B a b c d -B \,b^{2} c^{2}+B \,b^{2} d^{2}-2 C \,a^{2} c d -2 C a b \,c^{2}+2 C a b \,d^{2}+2 C \,b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(571\)
derivativedivides \(\frac {\frac {C \,a^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} c^{2} \tan \left (f x +e \right )^{3}}{3}-\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,a^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {B \,b^{2} c^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}-\tan \left (f x +e \right ) A \,b^{2} d^{2}-\tan \left (f x +e \right ) C \,b^{2} c^{2}+\tan \left (f x +e \right ) C \,b^{2} d^{2}-\tan \left (f x +e \right ) a^{2} C \,d^{2}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{4}}{4}+\frac {A \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{5}}{5}+\tan \left (f x +e \right ) A \,b^{2} c^{2}+\tan \left (f x +e \right ) C \,a^{2} c^{2}+\tan \left (f x +e \right ) A \,a^{2} d^{2}+\frac {\left (2 A \,a^{2} c d +2 A a b \,c^{2}-2 A a b \,d^{2}-2 A \,b^{2} c d +B \,a^{2} c^{2}-B \,a^{2} d^{2}-4 B a b c d -B \,b^{2} c^{2}+B \,b^{2} d^{2}-2 C \,a^{2} c d -2 C a b \,c^{2}+2 C a b \,d^{2}+2 C \,b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{2} c^{2}-A \,a^{2} d^{2}-4 A a b c d -A \,b^{2} c^{2}+A \,b^{2} d^{2}-2 B \,a^{2} c d -2 B a b \,c^{2}+2 B a b \,d^{2}+2 B \,b^{2} c d -C \,a^{2} c^{2}+a^{2} C \,d^{2}+4 C a b c d +C \,b^{2} c^{2}-C \,b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )+2 B a b c d \tan \left (f x +e \right )^{2}+\frac {4 C a b c d \tan \left (f x +e \right )^{3}}{3}+4 \tan \left (f x +e \right ) A a b c d -4 \tan \left (f x +e \right ) C a b c d +C a b \,c^{2} \tan \left (f x +e \right )^{2}+A \,b^{2} c d \tan \left (f x +e \right )^{2}+C \,a^{2} c d \tan \left (f x +e \right )^{2}+A a b \,d^{2} \tan \left (f x +e \right )^{2}+2 \tan \left (f x +e \right ) B a b \,c^{2}-2 \tan \left (f x +e \right ) B a b \,d^{2}-2 \tan \left (f x +e \right ) B \,b^{2} c d +\frac {C a b \,d^{2} \tan \left (f x +e \right )^{4}}{2}+\frac {C \,b^{2} c d \tan \left (f x +e \right )^{4}}{2}+\frac {2 B a b \,d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {2 B \,b^{2} c d \tan \left (f x +e \right )^{3}}{3}-C a b \,d^{2} \tan \left (f x +e \right )^{2}-C \,b^{2} c d \tan \left (f x +e \right )^{2}+2 \tan \left (f x +e \right ) B \,a^{2} c d}{f}\) \(770\)
default \(\frac {\frac {C \,a^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} c^{2} \tan \left (f x +e \right )^{3}}{3}-\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,a^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {B \,b^{2} c^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}-\tan \left (f x +e \right ) A \,b^{2} d^{2}-\tan \left (f x +e \right ) C \,b^{2} c^{2}+\tan \left (f x +e \right ) C \,b^{2} d^{2}-\tan \left (f x +e \right ) a^{2} C \,d^{2}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{4}}{4}+\frac {A \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{5}}{5}+\tan \left (f x +e \right ) A \,b^{2} c^{2}+\tan \left (f x +e \right ) C \,a^{2} c^{2}+\tan \left (f x +e \right ) A \,a^{2} d^{2}+\frac {\left (2 A \,a^{2} c d +2 A a b \,c^{2}-2 A a b \,d^{2}-2 A \,b^{2} c d +B \,a^{2} c^{2}-B \,a^{2} d^{2}-4 B a b c d -B \,b^{2} c^{2}+B \,b^{2} d^{2}-2 C \,a^{2} c d -2 C a b \,c^{2}+2 C a b \,d^{2}+2 C \,b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{2} c^{2}-A \,a^{2} d^{2}-4 A a b c d -A \,b^{2} c^{2}+A \,b^{2} d^{2}-2 B \,a^{2} c d -2 B a b \,c^{2}+2 B a b \,d^{2}+2 B \,b^{2} c d -C \,a^{2} c^{2}+a^{2} C \,d^{2}+4 C a b c d +C \,b^{2} c^{2}-C \,b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )+2 B a b c d \tan \left (f x +e \right )^{2}+\frac {4 C a b c d \tan \left (f x +e \right )^{3}}{3}+4 \tan \left (f x +e \right ) A a b c d -4 \tan \left (f x +e \right ) C a b c d +C a b \,c^{2} \tan \left (f x +e \right )^{2}+A \,b^{2} c d \tan \left (f x +e \right )^{2}+C \,a^{2} c d \tan \left (f x +e \right )^{2}+A a b \,d^{2} \tan \left (f x +e \right )^{2}+2 \tan \left (f x +e \right ) B a b \,c^{2}-2 \tan \left (f x +e \right ) B a b \,d^{2}-2 \tan \left (f x +e \right ) B \,b^{2} c d +\frac {C a b \,d^{2} \tan \left (f x +e \right )^{4}}{2}+\frac {C \,b^{2} c d \tan \left (f x +e \right )^{4}}{2}+\frac {2 B a b \,d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {2 B \,b^{2} c d \tan \left (f x +e \right )^{3}}{3}-C a b \,d^{2} \tan \left (f x +e \right )^{2}-C \,b^{2} c d \tan \left (f x +e \right )^{2}+2 \tan \left (f x +e \right ) B \,a^{2} c d}{f}\) \(770\)
parallelrisch \(\frac {20 C \,a^{2} d^{2} \tan \left (f x +e \right )^{3}+20 C \,b^{2} c^{2} \tan \left (f x +e \right )^{3}-20 C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}+30 B \,a^{2} d^{2} \tan \left (f x +e \right )^{2}+30 B \,b^{2} c^{2} \tan \left (f x +e \right )^{2}-30 B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}-60 \tan \left (f x +e \right ) A \,b^{2} d^{2}-60 \tan \left (f x +e \right ) C \,b^{2} c^{2}+60 \tan \left (f x +e \right ) C \,b^{2} d^{2}-60 \tan \left (f x +e \right ) a^{2} C \,d^{2}+15 B \,b^{2} d^{2} \tan \left (f x +e \right )^{4}+20 A \,b^{2} d^{2} \tan \left (f x +e \right )^{3}+12 C \,b^{2} d^{2} \tan \left (f x +e \right )^{5}+60 \tan \left (f x +e \right ) A \,b^{2} c^{2}+60 \tan \left (f x +e \right ) C \,a^{2} c^{2}+60 \tan \left (f x +e \right ) A \,a^{2} d^{2}+30 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c^{2}-30 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} d^{2}-30 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} c^{2}+30 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} d^{2}+120 B a b c d \tan \left (f x +e \right )^{2}+80 C a b c d \tan \left (f x +e \right )^{3}+240 \tan \left (f x +e \right ) A a b c d -240 \tan \left (f x +e \right ) C a b c d +60 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c d +60 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,c^{2}-60 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,d^{2}-60 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} c d -60 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c d -60 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,c^{2}+60 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,d^{2}+60 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} c d +60 C a b \,c^{2} \tan \left (f x +e \right )^{2}+60 A \,b^{2} c d \tan \left (f x +e \right )^{2}+60 C \,a^{2} c d \tan \left (f x +e \right )^{2}+60 A a b \,d^{2} \tan \left (f x +e \right )^{2}+120 \tan \left (f x +e \right ) B a b \,c^{2}-120 \tan \left (f x +e \right ) B a b \,d^{2}-120 \tan \left (f x +e \right ) B \,b^{2} c d +30 C a b \,d^{2} \tan \left (f x +e \right )^{4}+30 C \,b^{2} c d \tan \left (f x +e \right )^{4}+40 B a b \,d^{2} \tan \left (f x +e \right )^{3}+40 B \,b^{2} c d \tan \left (f x +e \right )^{3}-60 C a b \,d^{2} \tan \left (f x +e \right )^{2}-60 C \,b^{2} c d \tan \left (f x +e \right )^{2}+120 \tan \left (f x +e \right ) B \,a^{2} c d -120 B \,a^{2} c d f x -120 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b c d -240 A a b c d f x +240 C a b c d f x -120 B a b \,c^{2} f x +120 B a b \,d^{2} f x +120 B \,b^{2} c d f x +60 A \,a^{2} c^{2} f x -60 A \,a^{2} d^{2} f x -60 A \,b^{2} c^{2} f x +60 A \,b^{2} d^{2} f x -60 C \,a^{2} c^{2} f x +60 C \,a^{2} d^{2} f x +60 C \,b^{2} c^{2} f x -60 C \,b^{2} d^{2} f x}{60 f}\) \(933\)
risch \(\text {Expression too large to display}\) \(2496\)

input
int((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2), 
x,method=_RETURNVERBOSE)
 
output
1/2*(2*A*a^2*c*d+2*A*a*b*c^2+B*a^2*c^2)/f*ln(1+tan(f*x+e)^2)+(B*b^2*d^2+2* 
C*a*b*d^2+2*C*b^2*c*d)/f*(1/4*tan(f*x+e)^4-1/2*tan(f*x+e)^2+1/2*ln(1+tan(f 
*x+e)^2))+(A*b^2*d^2+2*B*a*b*d^2+2*B*b^2*c*d+C*a^2*d^2+4*C*a*b*c*d+C*b^2*c 
^2)/f*(1/3*tan(f*x+e)^3-tan(f*x+e)+arctan(tan(f*x+e)))+(A*a^2*d^2+4*A*a*b* 
c*d+A*b^2*c^2+2*B*a^2*c*d+2*B*a*b*c^2+C*a^2*c^2)/f*(tan(f*x+e)-arctan(tan( 
f*x+e)))+(2*A*a*b*d^2+2*A*b^2*c*d+B*a^2*d^2+4*B*a*b*c*d+B*b^2*c^2+2*C*a^2* 
c*d+2*C*a*b*c^2)/f*(1/2*tan(f*x+e)^2-1/2*ln(1+tan(f*x+e)^2))+A*a^2*c^2*x+C 
*b^2*d^2/f*(1/5*tan(f*x+e)^5-1/3*tan(f*x+e)^3+tan(f*x+e)-arctan(tan(f*x+e) 
))
 
3.1.58.5 Fricas [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 462, normalized size of antiderivative = 1.04 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {12 \, C b^{2} d^{2} \tan \left (f x + e\right )^{5} + 15 \, {\left (2 \, C b^{2} c d + {\left (2 \, C a b + B b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{4} + 20 \, {\left (C b^{2} c^{2} + 2 \, {\left (2 \, C a b + B b^{2}\right )} c d + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{3} + 60 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c^{2} - 2 \, {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c d - {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d^{2}\right )} f x + 30 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c^{2} + 2 \, {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c d + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{2} - 30 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c^{2} + 2 \, {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c d - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 60 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c^{2} + 2 \, {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c d + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{60 \, f} \]

input
integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+ 
e)^2),x, algorithm="fricas")
 
output
1/60*(12*C*b^2*d^2*tan(f*x + e)^5 + 15*(2*C*b^2*c*d + (2*C*a*b + B*b^2)*d^ 
2)*tan(f*x + e)^4 + 20*(C*b^2*c^2 + 2*(2*C*a*b + B*b^2)*c*d + (C*a^2 + 2*B 
*a*b + (A - C)*b^2)*d^2)*tan(f*x + e)^3 + 60*(((A - C)*a^2 - 2*B*a*b - (A 
- C)*b^2)*c^2 - 2*(B*a^2 + 2*(A - C)*a*b - B*b^2)*c*d - ((A - C)*a^2 - 2*B 
*a*b - (A - C)*b^2)*d^2)*f*x + 30*((2*C*a*b + B*b^2)*c^2 + 2*(C*a^2 + 2*B* 
a*b + (A - C)*b^2)*c*d + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d^2)*tan(f*x + e) 
^2 - 30*((B*a^2 + 2*(A - C)*a*b - B*b^2)*c^2 + 2*((A - C)*a^2 - 2*B*a*b - 
(A - C)*b^2)*c*d - (B*a^2 + 2*(A - C)*a*b - B*b^2)*d^2)*log(1/(tan(f*x + e 
)^2 + 1)) + 60*((C*a^2 + 2*B*a*b + (A - C)*b^2)*c^2 + 2*(B*a^2 + 2*(A - C) 
*a*b - B*b^2)*c*d + ((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*d^2)*tan(f*x + e 
))/f
 
3.1.58.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1134 vs. \(2 (396) = 792\).

Time = 0.30 (sec) , antiderivative size = 1134, normalized size of antiderivative = 2.56 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\text {Too large to display} \]

input
integrate((a+b*tan(f*x+e))**2*(c+d*tan(f*x+e))**2*(A+B*tan(f*x+e)+C*tan(f* 
x+e)**2),x)
 
output
Piecewise((A*a**2*c**2*x + A*a**2*c*d*log(tan(e + f*x)**2 + 1)/f - A*a**2* 
d**2*x + A*a**2*d**2*tan(e + f*x)/f + A*a*b*c**2*log(tan(e + f*x)**2 + 1)/ 
f - 4*A*a*b*c*d*x + 4*A*a*b*c*d*tan(e + f*x)/f - A*a*b*d**2*log(tan(e + f* 
x)**2 + 1)/f + A*a*b*d**2*tan(e + f*x)**2/f - A*b**2*c**2*x + A*b**2*c**2* 
tan(e + f*x)/f - A*b**2*c*d*log(tan(e + f*x)**2 + 1)/f + A*b**2*c*d*tan(e 
+ f*x)**2/f + A*b**2*d**2*x + A*b**2*d**2*tan(e + f*x)**3/(3*f) - A*b**2*d 
**2*tan(e + f*x)/f + B*a**2*c**2*log(tan(e + f*x)**2 + 1)/(2*f) - 2*B*a**2 
*c*d*x + 2*B*a**2*c*d*tan(e + f*x)/f - B*a**2*d**2*log(tan(e + f*x)**2 + 1 
)/(2*f) + B*a**2*d**2*tan(e + f*x)**2/(2*f) - 2*B*a*b*c**2*x + 2*B*a*b*c** 
2*tan(e + f*x)/f - 2*B*a*b*c*d*log(tan(e + f*x)**2 + 1)/f + 2*B*a*b*c*d*ta 
n(e + f*x)**2/f + 2*B*a*b*d**2*x + 2*B*a*b*d**2*tan(e + f*x)**3/(3*f) - 2* 
B*a*b*d**2*tan(e + f*x)/f - B*b**2*c**2*log(tan(e + f*x)**2 + 1)/(2*f) + B 
*b**2*c**2*tan(e + f*x)**2/(2*f) + 2*B*b**2*c*d*x + 2*B*b**2*c*d*tan(e + f 
*x)**3/(3*f) - 2*B*b**2*c*d*tan(e + f*x)/f + B*b**2*d**2*log(tan(e + f*x)* 
*2 + 1)/(2*f) + B*b**2*d**2*tan(e + f*x)**4/(4*f) - B*b**2*d**2*tan(e + f* 
x)**2/(2*f) - C*a**2*c**2*x + C*a**2*c**2*tan(e + f*x)/f - C*a**2*c*d*log( 
tan(e + f*x)**2 + 1)/f + C*a**2*c*d*tan(e + f*x)**2/f + C*a**2*d**2*x + C* 
a**2*d**2*tan(e + f*x)**3/(3*f) - C*a**2*d**2*tan(e + f*x)/f - C*a*b*c**2* 
log(tan(e + f*x)**2 + 1)/f + C*a*b*c**2*tan(e + f*x)**2/f + 4*C*a*b*c*d*x 
+ 4*C*a*b*c*d*tan(e + f*x)**3/(3*f) - 4*C*a*b*c*d*tan(e + f*x)/f + C*a*...
 
3.1.58.7 Maxima [A] (verification not implemented)

Time = 0.39 (sec) , antiderivative size = 463, normalized size of antiderivative = 1.05 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {12 \, C b^{2} d^{2} \tan \left (f x + e\right )^{5} + 15 \, {\left (2 \, C b^{2} c d + {\left (2 \, C a b + B b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{4} + 20 \, {\left (C b^{2} c^{2} + 2 \, {\left (2 \, C a b + B b^{2}\right )} c d + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{3} + 30 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c^{2} + 2 \, {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c d + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )^{2} + 60 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c^{2} - 2 \, {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c d - {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d^{2}\right )} {\left (f x + e\right )} + 30 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c^{2} + 2 \, {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c d - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 60 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c^{2} + 2 \, {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c d + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{60 \, f} \]

input
integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+ 
e)^2),x, algorithm="maxima")
 
output
1/60*(12*C*b^2*d^2*tan(f*x + e)^5 + 15*(2*C*b^2*c*d + (2*C*a*b + B*b^2)*d^ 
2)*tan(f*x + e)^4 + 20*(C*b^2*c^2 + 2*(2*C*a*b + B*b^2)*c*d + (C*a^2 + 2*B 
*a*b + (A - C)*b^2)*d^2)*tan(f*x + e)^3 + 30*((2*C*a*b + B*b^2)*c^2 + 2*(C 
*a^2 + 2*B*a*b + (A - C)*b^2)*c*d + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d^2)*t 
an(f*x + e)^2 + 60*(((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*c^2 - 2*(B*a^2 + 
 2*(A - C)*a*b - B*b^2)*c*d - ((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*d^2)*( 
f*x + e) + 30*((B*a^2 + 2*(A - C)*a*b - B*b^2)*c^2 + 2*((A - C)*a^2 - 2*B* 
a*b - (A - C)*b^2)*c*d - (B*a^2 + 2*(A - C)*a*b - B*b^2)*d^2)*log(tan(f*x 
+ e)^2 + 1) + 60*((C*a^2 + 2*B*a*b + (A - C)*b^2)*c^2 + 2*(B*a^2 + 2*(A - 
C)*a*b - B*b^2)*c*d + ((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*d^2)*tan(f*x + 
 e))/f
 
3.1.58.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 11957 vs. \(2 (436) = 872\).

Time = 10.52 (sec) , antiderivative size = 11957, normalized size of antiderivative = 26.99 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\text {Too large to display} \]

input
integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+ 
e)^2),x, algorithm="giac")
 
output
1/60*(60*A*a^2*c^2*f*x*tan(f*x)^5*tan(e)^5 - 60*C*a^2*c^2*f*x*tan(f*x)^5*t 
an(e)^5 - 120*B*a*b*c^2*f*x*tan(f*x)^5*tan(e)^5 - 60*A*b^2*c^2*f*x*tan(f*x 
)^5*tan(e)^5 + 60*C*b^2*c^2*f*x*tan(f*x)^5*tan(e)^5 - 120*B*a^2*c*d*f*x*ta 
n(f*x)^5*tan(e)^5 - 240*A*a*b*c*d*f*x*tan(f*x)^5*tan(e)^5 + 240*C*a*b*c*d* 
f*x*tan(f*x)^5*tan(e)^5 + 120*B*b^2*c*d*f*x*tan(f*x)^5*tan(e)^5 - 60*A*a^2 
*d^2*f*x*tan(f*x)^5*tan(e)^5 + 60*C*a^2*d^2*f*x*tan(f*x)^5*tan(e)^5 + 120* 
B*a*b*d^2*f*x*tan(f*x)^5*tan(e)^5 + 60*A*b^2*d^2*f*x*tan(f*x)^5*tan(e)^5 - 
 60*C*b^2*d^2*f*x*tan(f*x)^5*tan(e)^5 - 30*B*a^2*c^2*log(4*(tan(f*x)^2*tan 
(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^ 
2 + 1))*tan(f*x)^5*tan(e)^5 - 60*A*a*b*c^2*log(4*(tan(f*x)^2*tan(e)^2 - 2* 
tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*ta 
n(f*x)^5*tan(e)^5 + 60*C*a*b*c^2*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*t 
an(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^5*t 
an(e)^5 + 30*B*b^2*c^2*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1) 
/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^5*tan(e)^5 - 
60*A*a^2*c*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x) 
^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^5*tan(e)^5 + 60*C*a^2*c 
*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^ 
2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^5*tan(e)^5 + 120*B*a*b*c*d*log(4* 
(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + ta...
 
3.1.58.9 Mupad [B] (verification not implemented)

Time = 8.36 (sec) , antiderivative size = 561, normalized size of antiderivative = 1.27 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=x\,\left (A\,a^2\,c^2-A\,a^2\,d^2-A\,b^2\,c^2+A\,b^2\,d^2-C\,a^2\,c^2+C\,a^2\,d^2+C\,b^2\,c^2-C\,b^2\,d^2-2\,B\,a\,b\,c^2+2\,B\,a\,b\,d^2-2\,B\,a^2\,c\,d+2\,B\,b^2\,c\,d-4\,A\,a\,b\,c\,d+4\,C\,a\,b\,c\,d\right )-\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {B\,a^2\,d^2}{2}-\frac {B\,a^2\,c^2}{2}+\frac {B\,b^2\,c^2}{2}-\frac {B\,b^2\,d^2}{2}-A\,a\,b\,c^2+A\,a\,b\,d^2-A\,a^2\,c\,d+C\,a\,b\,c^2+A\,b^2\,c\,d-C\,a\,b\,d^2+C\,a^2\,c\,d-C\,b^2\,c\,d+2\,B\,a\,b\,c\,d\right )}{f}+\frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {B\,a^2\,d^2}{2}+\frac {B\,b^2\,c^2}{2}-\frac {b\,d\,\left (B\,b\,d+2\,C\,a\,d+2\,C\,b\,c\right )}{2}+A\,a\,b\,d^2+C\,a\,b\,c^2+A\,b^2\,c\,d+C\,a^2\,c\,d+2\,B\,a\,b\,c\,d\right )}{f}+\frac {{\mathrm {tan}\left (e+f\,x\right )}^3\,\left (\frac {A\,b^2\,d^2}{3}+\frac {C\,a^2\,d^2}{3}+\frac {C\,b^2\,c^2}{3}-\frac {C\,b^2\,d^2}{3}+\frac {2\,B\,a\,b\,d^2}{3}+\frac {2\,B\,b^2\,c\,d}{3}+\frac {4\,C\,a\,b\,c\,d}{3}\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (A\,a^2\,d^2+A\,b^2\,c^2-A\,b^2\,d^2+C\,a^2\,c^2-C\,a^2\,d^2-C\,b^2\,c^2+C\,b^2\,d^2+2\,B\,a\,b\,c^2-2\,B\,a\,b\,d^2+2\,B\,a^2\,c\,d-2\,B\,b^2\,c\,d+4\,A\,a\,b\,c\,d-4\,C\,a\,b\,c\,d\right )}{f}+\frac {b\,d\,{\mathrm {tan}\left (e+f\,x\right )}^4\,\left (B\,b\,d+2\,C\,a\,d+2\,C\,b\,c\right )}{4\,f}+\frac {C\,b^2\,d^2\,{\mathrm {tan}\left (e+f\,x\right )}^5}{5\,f} \]

input
int((a + b*tan(e + f*x))^2*(c + d*tan(e + f*x))^2*(A + B*tan(e + f*x) + C* 
tan(e + f*x)^2),x)
 
output
x*(A*a^2*c^2 - A*a^2*d^2 - A*b^2*c^2 + A*b^2*d^2 - C*a^2*c^2 + C*a^2*d^2 + 
 C*b^2*c^2 - C*b^2*d^2 - 2*B*a*b*c^2 + 2*B*a*b*d^2 - 2*B*a^2*c*d + 2*B*b^2 
*c*d - 4*A*a*b*c*d + 4*C*a*b*c*d) - (log(tan(e + f*x)^2 + 1)*((B*a^2*d^2)/ 
2 - (B*a^2*c^2)/2 + (B*b^2*c^2)/2 - (B*b^2*d^2)/2 - A*a*b*c^2 + A*a*b*d^2 
- A*a^2*c*d + C*a*b*c^2 + A*b^2*c*d - C*a*b*d^2 + C*a^2*c*d - C*b^2*c*d + 
2*B*a*b*c*d))/f + (tan(e + f*x)^2*((B*a^2*d^2)/2 + (B*b^2*c^2)/2 - (b*d*(B 
*b*d + 2*C*a*d + 2*C*b*c))/2 + A*a*b*d^2 + C*a*b*c^2 + A*b^2*c*d + C*a^2*c 
*d + 2*B*a*b*c*d))/f + (tan(e + f*x)^3*((A*b^2*d^2)/3 + (C*a^2*d^2)/3 + (C 
*b^2*c^2)/3 - (C*b^2*d^2)/3 + (2*B*a*b*d^2)/3 + (2*B*b^2*c*d)/3 + (4*C*a*b 
*c*d)/3))/f + (tan(e + f*x)*(A*a^2*d^2 + A*b^2*c^2 - A*b^2*d^2 + C*a^2*c^2 
 - C*a^2*d^2 - C*b^2*c^2 + C*b^2*d^2 + 2*B*a*b*c^2 - 2*B*a*b*d^2 + 2*B*a^2 
*c*d - 2*B*b^2*c*d + 4*A*a*b*c*d - 4*C*a*b*c*d))/f + (b*d*tan(e + f*x)^4*( 
B*b*d + 2*C*a*d + 2*C*b*c))/(4*f) + (C*b^2*d^2*tan(e + f*x)^5)/(5*f)